package com.objecteffects.ilmp.web.inject;

import com.google.inject.AbstractModule;
import com.google.inject.matcher.Matchers;
import com.google.inject.persist.jpa.JpaPersistModule;

import com.objecteffects.ilmp.persist.api.IBlogPostsOffsetEntityDao;
import com.objecteffects.ilmp.persist.api.ITumblrBlogEntityDao;
import com.objecteffects.ilmp.persist.api.IUserEntityDao;
import com.objecteffects.ilmp.persist.jpa.BlogPostsOffsetEntityDao;
import com.objecteffects.ilmp.persist.jpa.TumblrBlogEntityDao;
import com.objecteffects.ilmp.persist.jpa.UserEntityDao;
import com.objecteffects.ilmp.util.logger.Slf4jTypeListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Rusty Wright
 */
public class JpaConfigureModule extends AbstractModule {
    private final transient Logger log = LoggerFactory
        .getLogger(JpaConfigureModule.class);

    @Override
    protected void configure() {
        this.log.debug("configure");

        this.bindListener(Matchers.any(), new Slf4jTypeListener());

        this.install(new JpaPersistModule("ilmp"));

        this.bind(IUserEntityDao.class).to(UserEntityDao.class);

        this.bind(ITumblrBlogEntityDao.class).to(TumblrBlogEntityDao.class);

        this.bind(IBlogPostsOffsetEntityDao.class)
        .to(BlogPostsOffsetEntityDao.class);
    }
}
